/**
 * 
 */
package neptune.manager.model.topology;

import java.util.ArrayList;

/**
 * @author Roberto Bifulco [info@robertobifulco.it, robertobifulco.it]
 * 
 */
public class Link {

	/**
	 * Multiplexing techs
	 */
	public static final int UNDEFINED = -1;
	public static final int ONE_LINK_PER_INTERFACE = 0;
	public static final int IP_ALIASING = 1;

	/**
	 * Il punto di partenza del link
	 */
	private EndPoint source;
	/**
	 * il punto di arrivo del link
	 */
	private EndPoint destination;
	/**
	 * Identificativo univoco del link
	 */
	private String id;
	/**
	 * Le Property associate a questo link
	 */
	private ArrayList<Property> properties = new ArrayList<Property>(0);
	/**
	 * true se e' un link full duplex
	 */
	private boolean isFullDuplex;

	/**
	 * @return the source
	 */
	public EndPoint getSource() {
		return source;
	}

	/**
	 * @param source
	 *            the source to set
	 */
	public void setSource(EndPoint source) {
		this.source = source;
	}

	/**
	 * @return the destination
	 */
	public EndPoint getDestination() {
		return destination;
	}

	/**
	 * @param destination
	 *            the destination to set
	 */
	public void setDestination(EndPoint destination) {
		this.destination = destination;
	}

	/**
	 * @return the properties
	 */
	public Property[] getProperties() {
		return (Property[]) properties.toArray(new Property[0]);
	}

	/**
	 * @param properties
	 *            the properties to set
	 */
	public void addProperty(Property property) {
		this.properties.add(property);
	}

	/**
	 * @return the isFullDuplex
	 */
	public boolean isFullDuplex() {
		return isFullDuplex;
	}

	/**
	 * @param isFullDuplex
	 *            the isFullDuplex to set
	 */
	public void setFullDuplex(boolean isFullDuplex) {
		this.isFullDuplex = isFullDuplex;
	}

	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(String id) {
		// TODO gestire l'univocita' dell'id
		this.id = id;
	}

	/**
	 * @param id
	 * @param source
	 * @param destination
	 * @param isFullDuplex
	 */
	public Link(String id, EndPoint source, EndPoint destination,
			boolean isFullDuplex) {
		// TODO gestire univocita' id
		this.id = id;
		this.source = source;
		this.destination = destination;
		this.isFullDuplex = isFullDuplex;
		properties = new ArrayList<Property>(1);
	}

	public static String getMultiplexingTechLabel(int multiplexingTech) {
		switch (multiplexingTech) {
		case IP_ALIASING:
			return "ipAliasing";
		case ONE_LINK_PER_INTERFACE:
			return "OLPI";
		default:
			return "undefined";
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {

			return id;
	}

}